var _n13;
var cc__extends = __extends;
var cc__decorate = __decorate;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $1$Loader = require("Loader");
var s = cc__importDefault($1$Loader);
var $1$yyComponent = require("yyComponent");
var c = cc__importDefault($1$yyComponent);
var $gameMode_Json = require("gameMode_Json");
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_HomeTujian = function (t) {
  function _ctor() {
    // 调用t函数，如果返回null则使用this
    const e = null !== t && t.apply(this, arguments) || this;

    // 设置对象的初始属性
    e.content = null;
    e.pageNode = null;
    e.tutjiannumber = 40; // 设定默认的tutjiannumber
    e.pageNumber = 6;      // 设定默认的pageNumber

    // 返回对象
    return e;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () {
    this.initScr();
  };
  _ctor.prototype.initScr = function () {
    const t = this;
    const e = $zqcc_OverallSystem.sers().userSrv.getFeibiaoData().level;
    const totalPages = Math.ceil(this.tutjiannumber / this.pageNumber);

    // 创建和添加页面节点
    for (let n = 1; n < totalPages; n++) {
      const pageNodeInstance = cc.instantiate(this.pageNode);
      this.node.getComponent(cc.PageView).addPage(pageNodeInstance);
      pageNodeInstance.parent = this.content;
    }

    // 延迟函数（可添加具体逻辑）
    this.scheduleOnce(function () { });

    // 声明局部变量
    const r = e;

    // 加载每个节点的内容
    const loadNodeContent = function (o) {
      if (o < t.tutjiannumber) {
        s.default.loadBundleRes("home", "tujian/" + (o + 1), function (n) {
          if (t && t.node) {
            const pageIndex = Math.floor(o / t.pageNumber);
            const itemNode = t.content.children[pageIndex].children[o % t.pageNumber];
            itemNode.active = true;
            itemNode.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(n);

            if (e < o + 2 || e === 0) {
              itemNode.getChildByName("icon").color = new cc.Color(68, 68, 68, 255);
              itemNode.getChildByName("weijiesuo").active = true;
              itemNode.getChildByName("icon").active = false;

              if (r - 1 === o || (e === 0 && o === 0)) {
                itemNode.getChildByName("weijiesuo").children[0].active = true;
                itemNode.on(cc.Node.EventType.TOUCH_START, function () {
                  $zqcc_OverallSystem.mgrs().soundMgr.playBtnSound();
                  $zqcc_OverallSystem.mgrs().gameMgr.enterMode($gameMode_Json.GAME_MODE.Feibiao, true);
                }, t);
              } else {
                itemNode.getChildByName("weijiesuo").children[1].active = true;
              }
            } else {
              const randomValue1 = 5 * Math.random() + 2;
              const randomValue2 = 5 * Math.random() + 2;
              t.huangdong(itemNode, true, randomValue2, randomValue1);
            }
          }
        });
      } else {
        const pageIndex = Math.floor(o / c.pageNumber);
        const itemNode = c.content.children[pageIndex].children[o % c.pageNumber];
        itemNode.active = true;
        itemNode.getChildByName("weijiesuo").active = true;
        itemNode.getChildByName("icon").active = false;
        itemNode.getChildByName("weijiesuo").children[2].active = true;
      }
    };

    // 向每个节点加载内容
    for (let n = 0; n <= this.tutjiannumber; n++) {
      loadNodeContent(n);
    }
  };
  _ctor.prototype.huangdong = function (t, e, o, n) {
    const i = this;

    // 设置默认值
    e = e !== undefined ? e : true; // 默认值为true
    o = o !== undefined ? o : 5;     // 默认值为5

    // 如果t存在且有parent属性
    if (t && t.parent) {
      // 确定角度的正负
      o = e ? Math.abs(o) : -Math.abs(o);

      // 创建并启动动画
      cc.tween(t)
        .to(n, { angle: o }) // 设置目标角度
        .call(() => {
          i.huangdong(t, !e, o, n); // 动画完成后调用huangdong方法
        })
        .start(); // 开始动画
    }
  };
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "content", undefined);
  cc__decorate([ccp_property(cc.Node)], _ctor.prototype, "pageNode", undefined);
  return cc__decorate([ccp_ccclass], _ctor);
}(c.default);
exports.default = def_HomeTujian;